package pers.cz.orm.tools;

import pers.cz.codegen.codegen.CodeGenerator;
import pers.cz.codegen.enums.DbConfigItem;
import pers.cz.jefconfig.config.JefConfiguration;
import pers.cz.orm.entity.template.EntityCodeGenerator;

/**
 * @program: jef-orm
 * @description: 实体类代码生成
 * @author: Cheng Zhi
 * @create: 2023-08-31 17:28
 **/
public class EntityCodeGenUtils {

    public static void main(String[] args) throws Exception {

        String tableName = "AID2.IMS_JSON_SOAP_1_1";
        String fileFolder = "orm-core\\src\\test\\java";
        String packageName = "pers.cz.orm.entity";
        codeGen(tableName, fileFolder, packageName);
    }

    public static void codeGen(String tableName, String fileFolder, String packageName) throws Exception {
        CodeGenerator codeGenerator = new EntityCodeGenerator(tableName);
        JefConfiguration.set(DbConfigItem.DB_URL, JefConfiguration.get(pers.cz.orm.enums.DbConfigItem.MASTER_DB_URL));
        JefConfiguration.set(DbConfigItem.DB_USERNAME, JefConfiguration.get(pers.cz.orm.enums.DbConfigItem.MASTER_DB_USERNAME));
        JefConfiguration.set(DbConfigItem.DB_PASSWORD, JefConfiguration.get(pers.cz.orm.enums.DbConfigItem.MASTER_DB_PASSWORD));
        codeGenerator.setFileFolder(fileFolder);
        codeGenerator.setIpackage(packageName);
        codeGenerator.generateCode();
    }
}
